package logic

import (
	"context"
	"logincheck/model/mysql"

	"logincheck/logincheckrpc/internal/svc"
	"logincheck/logincheckrpc/logincheckrpc"

	"github.com/zeromicro/go-zero/core/logx"
)

type GoodsListLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewGoodsListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GoodsListLogic {
	return &GoodsListLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *GoodsListLogic) GoodsList(in *logincheckrpc.GoodsListRequest) (*logincheckrpc.GoodsListResponse, error) {
	// todo: add your logic here and delete this line
	var list []*logincheckrpc.GoodsList
	list, err := mysql.GoodsList(mysql.DB, in.UserId)
	if err != nil {
		return nil, err
	}
	return &logincheckrpc.GoodsListResponse{
		List: list,
	}, nil
}
